package
{
	import com.mcglib.flac.FixedList;
	import com.mcglib.flac.FlacUtils;
	
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class FixedListTest extends Sprite
	{
		private var flist:FixedList = new FixedList;
		
		private var datas:Array = [];
		
		public function FixedListTest()
		{
			super();
			
			var lui:MovieClip = new fixedListUI;
			addChild(lui);
			
			//指定item ui的实例
			flist.renderInstances  =  FlacUtils.getUiInstancesByReg(lui,"item?",1,5);
			//指定IDataRenderer的类型
			flist.rendererClass= Renderer;
			//呈现
			flist.present();
			
			lui.btnAdd.addEventListener(MouseEvent.CLICK,updateData);
			lui.btnDec.addEventListener(MouseEvent.CLICK,updateData);
		}
		
		private function updateData(e:MouseEvent):void{
			var btn:SimpleButton = e.currentTarget as SimpleButton;
			if(btn.name=="btnAdd"){
				datas.push(datas.length);
			}else if(datas.length>0){
				datas.splice(datas.length-1,1);
			}
			
			flist.dataProvide = datas;
			flist.present();
		}
	}
}